package com.bsoft.gol.hcs.specialist.service.impl;

import ctd.spring.boot.annotation.SsdevService;
import ctd.util.annotation.RpcService;
import opensource.jpinyin.PinyinHelper;
import org.springframework.beans.factory.annotation.Autowired;
import com.bsoft.gol.hcs.specialist.bean.request.SurgicalRecordRequest;
import com.bsoft.gol.hcs.specialist.bean.response.SurgicalInfoResponse;
import com.bsoft.gol.hcs.specialist.service.ISurgicalRecordService;
import com.bsoft.gol.hcs.utils.CommonUtils;
import com.bsoft.gol.hcs.visitrecord.dao.VrSurgicalRecordDAO;

import java.util.ArrayList;
import java.util.List;

/**
 * 手术信息实现类
 *
 * @author lanyu
 * @date 2021年10月15日 13:56
 */
@SsdevService("surgicalRecordService")
public class SurgicalRecordServiceImpl implements ISurgicalRecordService {

    @Autowired
    private VrSurgicalRecordDAO vrSurgicalRecordDAO;


    @Override
    @RpcService
    public List<SurgicalInfoResponse> querySurgicalInfoList(SurgicalRecordRequest request) {
        List<SurgicalInfoResponse> surgicalInfoResponseList = vrSurgicalRecordDAO.querySurgicalInfoList();
        List<SurgicalInfoResponse> responseList = new ArrayList<>();
        if (CommonUtils.isNotEmpty(request.getSurgicalName())) {
            for (SurgicalInfoResponse surgicalInfo : surgicalInfoResponseList) {
                if (PinyinHelper.getShortPinyin(surgicalInfo.getOperationName()).contains(request.getSurgicalName()) || surgicalInfo.getOperationName().contains(request.getSurgicalName())) {
                    responseList.add(surgicalInfo);
                }
            }
            return responseList;
        }else{
            return surgicalInfoResponseList;
        }
    }
}
